Open
Conversation
added 6 commits
April 9, 2012 18:27
This allows running the test module without manually having to update the PYTHONPATH. The recommended way, however, to run the tests is: python2 -m unittest pgpdump.test
This changes the interface of the function but I don't want to replicate
that function in all the filters that I apply on top of the parsed data.
My usecase is smth like this:
for filename in sys.argv[1:]:
for packet in ifilter(filter, parsefile(filename)):
print(packet)
I was hesitating to add this, because it's a calculation that is not necessarily needed by the user of pgpdump. But then again, that is the case for nearly every data computed by pgpdump. It'd probably be smart to make all fields needing calculation a lazy Property() and update the fields after calculation.
I introduced a NameError at some stage:
File "/home/muelli/vcs/python-pgpdump/pgpdump/__main__.py", line 13, in parsefile
for packet in data.packets():
File "/home/muelli/vcs/python-pgpdump/pgpdump/data.py", line 34, in packets
total_length, packet = construct_packet(self.data, offset)
File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 590, in construct_packet
packet = PacketType(tag, name, new, packet_data)
File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 148, in __init__
super(SignaturePacket, self).__init__(*args, **kwargs)
File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 22, in __init__
self.parse()
File "/home/muelli/vcs/python-pgpdump/pgpdump/packet.py", line 166, in parse
"%02x" % (offset, data[offset]))
NameError: global name 'data' is not defined
It should have been self.data of course.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So it helps to debug the issues arising.
The tests pass so I think the modifications made are correct.